package gradle.java.demo;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.Flow;
import java.util.concurrent.SubmissionPublisher;

@Slf4j
public class App {

    public static void main(String[] args) throws InterruptedException {
        Flow.Subscriber<String> subscriber = new MsgSubscriber();
        MsgProcessor processor = new MsgProcessor();
        processor.subscribe(subscriber);
        SubmissionPublisher<String> publisher = new SubmissionPublisher<>();
        publisher.subscribe(processor);
        for (int i = 0; i < 10; i++) {
            publisher.submit("jasonfu");
        }
        publisher.close();
        Thread.currentThread().join();
    }
}
